﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Demo1
{
    /// <summary>
    /// IncValue1 的摘要说明
    /// </summary>
    public class IncValue1 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            #region 取得number的数值
            context.Response.ContentType = "text/plain";
            string ispostback = context.Request.Form["ispostback"].ToString();
            string number = context.Request.Form["number"].ToString();
            if (ispostback == "true")
            {
                int temp = Int32.Parse(number);
                temp++;
                number = temp.ToString();
            }
            else
            {
                number = "0";
            }
            
            #endregion

            #region 输出number的值
            string fullPath = context.Server.MapPath("IncValue1.htm");
            string strHtmlContext = System.IO.File.ReadAllText(fullPath);
            strHtmlContext = strHtmlContext.Replace("@value", number);
            context.Response.Write(strHtmlContext);
            #endregion

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}